<template>
  <div id="PoParticulars">
    <v-tableTitle :btnConfig="btnConfig"
                  :tableSelectData="tableSelectData" @close="close"></v-tableTitle>
    <v-table
        :pageSize="pageSize"
        :page="page"
        :tableConfig="tableConfig"
        :tableData="tableData"
        :total="total"
        @findData="getTableData"
        @getTableData="getTableData"
        @searhData="searhData"
        @selectData="selectData"
        @setdialog="setdialog"
        @upData="getTableData"
        ref="table"
    ></v-table>
  </div>
</template>

<script>
import tableTitle from "commons/TableTitle";
import table from "commons/Table";
import baseMixin from "@/mixins/BaseMixin";

export default {
  name: "PoParticulars",
  mixins: [baseMixin],
  data() {
    return {
      btnConfig: [
        { label: this.$t('common.close'), invalid: "close" }
      ],
      routeData: {},
      tableConfig: [
        {
          label: this.$t('in.pokey1'),
          prop: "pokey",
          input: "input"
        },
        {
          label: this.$t('in.storerkey'),
          prop: "storerkey",
          input: "input"
        },
        {
          label: this.$t('outbound.userlinenumber'),
          prop: "polinenumber",
          input: "input"
        },
        {
          label: this.$t('config.sku'),
          prop: "sku",
          input: "input"
        },
        {
          label: this.$t('common.desc'),
          prop: "skudescription",
          input: "input"
        },
        {
          label: this.$t('config.packaging'),
          prop: "packkey",
          input: "input"
        },
        {
          label: this.$t('config.measureUnit'),
          prop: "uom",
          input: "input"
        },
        {
          label: this.$t('common.status'),
          prop: "status",
          input: "select",
          options: this.getOptions("codelkup/POSTATUS")
        },
        {
          label: this.$t('in.qtyordered'),
          prop: "qtyordered",
          input: "input"
        },
        {
          label: this.$t('in.qtyreceived'),
          prop: "qtyreceived",
          input: "input"
        }

      ],
      tableData: [],
      page: 1,
      pageSize: 10,
      total: 0,
      tableSelectData: [],
      tableSearhData: {}
    };
  },
  created() {
  },
  methods: {
    close() {
      this.$router.push({ name: "poQuery" });
    },
    //选中的内容
    selectData(data) {
      this.tableSelectData = data;
    },
    async getTableData(page, data) {
      try {
        let res = await this.$api.post(`/detail/queryListOfPo/1/${page}`, { pokey: this.routeData.pokey, ...data });
        
          this.tableData = res.page.list;
          this.page = res.page.curPage;
          this.pageSize = res.page.pageSize;
          this.total = res.page.total;
      } catch (e) {
        this.$message.error(e);
      }
    },
    searhData(data, up) {
      if (!up) {
        this.tableSearhData = data;
      } else {
        this.tableSearhData = data;
        this.getTableData(1, this.tableSearhData);
      }
    },
    setdialog(data) {
      this.$store.commit("setTemporary", data);
      this.$router.push({ name: "poQueryDeawer" });
    }

  },
  mounted() {
    this.routeData = this.$store.state.routeData;
    this.getTableData(1, {});
  },
  watch: {},
  components: {
    "v-tableTitle": tableTitle,
    "v-table": table
  }
};
</script>

<style scoped>

</style>